import React from 'react'
import { CellBody, Select, Form, FormCell, CellHeader, CellsTitle, Label, Button } from 'react-weui'
export default class ProductSelectNum extends React.Component {
	constructor(props) {
		super(props)
		this.state = {
            num: 1
		}
	}
	handlePlusNum() {
		var num = this.state.num;
		num++;
	    this.setState({
	    	num: num
	    });
	    this.props.getBuyNum(num);
	}
	handleMinusNum() {
		var num = this.state.num;
		if(num === 1) return;
		num--;
        this.setState({
        	num: num
        });
        this.props.getBuyNum(num);
	}
	render() {
		return (
			 <Form>
               <CellsTitle>选择数量</CellsTitle>
                <FormCell>
                    <CellHeader style={{fontSize: '0.8em' }}>
                        <Label>商品数量</Label>
                    </CellHeader>
                    <CellBody>
	                    <div className="sel-num-area sel-num-btn" style={{
	                    	padding: '1px 12px'
	                    }} onClick={this.handleMinusNum.bind(this)}>
	                        -
	                    </div>
	                     <div className="sel-num-area" style={{
	                     	padding: '1px 16px'
	                     }}>
	                         {this.state.num}
	                     </div>
	                    <div className="sel-num-area sel-num-btn" style={{
	                    	padding: '1px 12px'
	                    }} onClick={this.handlePlusNum.bind(this)}>
	                        +
	                    </div>
                    </CellBody>
                </FormCell>
            </Form>
		);
	}
}
